package com.bw.zg3park2212.user

import android.annotation.SuppressLint
import android.webkit.JavascriptInterface

import com.alibaba.android.arouter.facade.annotation.Route
import com.bw.base.mvvm.BaseViewActivity
import com.bw.zg3park2212.databinding.ActivityWebBinding
import com.tencent.smtt.sdk.WebView
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path="/app/WebActivity")
class WebActivity : BaseViewActivity<ActivityWebBinding>() {
    var web: WebView?=null
    @SuppressLint("JavascriptInterface")
    override fun intitView() {
        web=binding.web
        web?.apply {
            loadUrl("file:///android_asset/test.html")
            settings.javaScriptEnabled=true//允许和js交互
            //js调安卓步骤1
            addJavascriptInterface(this@WebActivity,"android")
        }
        binding.btnJs.setOnClickListener {
            web!!.loadUrl("javascript:harmonyCallJS()")
        }
    }
    @JavascriptInterface
    fun harmonyAgree():String{
        return "hello"
    }
    override fun intitData() {

    }

}